package cn.stylefeng.guns.modular.ry600.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.stylefeng.roses.core.base.controller.BaseController;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;








import cn.stylefeng.guns.core.log.LogObjectHolder;

import org.springframework.web.bind.annotation.RequestParam;

import com.baomidou.mybatisplus.plugins.Page;
import com.github.pagehelper.PageHelper;

import cn.stylefeng.guns.modular.system.model.Client;
import cn.stylefeng.guns.modular.ry600.service.IClientService;
import cn.stylefeng.guns.modular.ry600.service.IErpCustomerService;
import cn.stylefeng.guns.modular.ry600.service.IErpProductPriceService;
import cn.stylefeng.guns.modular.ry600.service.IErpProductService;
import cn.stylefeng.guns.modular.ry600.service.IErpProductStockService;

/**
 * 连锁客户验证管理控制器
 *
 * @author fengshuonan
 * @Date 2018-12-06 18:35:42
 */
@Controller
@RequestMapping("/erpproductstock")
public class ErpProductStockController extends BaseController {

//    private String PREFIX = "/ry600/client/";
	private String PREFIX = "/ry600/erpcustomer/";

    @Autowired
    private IErpProductStockService erpProductStockService;

    /**
     * 跳转到连锁客户验证管理首页
     */
    @RequestMapping("")
    public String index() {
//        return PREFIX + "client.html";
    	return PREFIX + "erpproduct.html";
    }

    
    
    /**
     * 连锁客户条件查找
     */
    @RequestMapping(value = "/selectByMsg")
    @ResponseBody
    public Object selectByMsg(HttpServletRequest request, HttpServletResponse response) {
    	
    	if(!StringUtils.isBlank(request.getParameter("page")) && !StringUtils.isBlank(request.getParameter("rows"))){
	    	Integer page = Integer.valueOf(request.getParameter("page"));
			Integer rows = Integer.valueOf(request.getParameter("rows"));
			PageHelper.startPage(page, rows);
    		
    	}
    	Map<String, Object> msg=this.setMap(request);
    	Object result=erpProductStockService.selectByMsg(msg);
    	
    	return result;
        
    }
    
    public Map<String,Object> setMap(HttpServletRequest request){
    	Map<String, Object> msg = new HashMap<String, Object>();
    	String ifUse=request.getParameter("ifUse");
    	String searchKey = request.getParameter("searchKey");
		String searchWord = request.getParameter("searchWord");
		if (!StringUtils.isBlank(ifUse)) {
			msg.put("ifUse", ifUse.trim());
		}
		if (!StringUtils.isBlank(searchKey) && !StringUtils.isBlank(searchWord)) {
			msg.put(searchKey.trim(), searchWord.trim());
		}
		return msg;
    }
    
}
